package com.study.enums;

/**
 * @author CSDN 流放深圳
 * @description 许可证书校验信息枚举类
 * @create 2024-04-13 15:55
 * @since 1.0.0
 */
public enum LicenceEnum {

    SUCCESS(0, "success"),
    NOT_FOUND(1, "Licence not found or empty.许可证书不存在或内容为空"),
    INVALID(2, "Licence is invalid.许可证书无效"),
    EXPIRE(3, "Licence is expire.许可证书已过期，请更换"),
    OUT_OF_TIME(4, "Licence is out_of_time.许可证书未在有效的授权时间内"),
    ILLEGALLY_STOLEN(5, "Licence is illegally stolen.许可证书被非法盗用"),

    ;

    private final Integer code;

    private final String des;

    LicenceEnum(Integer code, String des) {
        this.code = code;
        this.des = des;
    }

    public Integer getCode() {
        return this.code;
    }

    public String getDes() {
        return this.des;
    }

    /**
     * 根据 code 获取 value
     * @param code
     * @return
     */
    public static String getDescByCode(Integer code){
        for (LicenceEnum value : LicenceEnum.values()) {
            if(value.getCode().equals(code)){
                return value.getDes();
            }
        }
        return null;
    }
}
